package com.graduation.sports.presenter;


import com.graduation.sports.bean.UserInfo;
import com.graduation.sports.contract.LoginContract;

import org.litepal.LitePal;

import java.util.List;

/**
 * @ProjectName: botanyEncyclopedia
 * @Package: com.graduation.botanyencyclopedia.presenter
 * @ClassName: LoginPresenter
 * @Description: java类作用描述
 * @Author: APC
 * @CreateDate: 2021/2/5 9:35
 * @Version: 1.0
 */
public class LoginPresenter implements LoginContract.Presenter {
    protected LoginContract.View mView;

    public LoginPresenter(LoginContract.View view) {
        mView = view;
    }

    @Override
    public void login(String name, String pwd) {
        List<UserInfo> userInfoList  = LitePal.where("userAccount = ? and password = ?", name , pwd).find(UserInfo.class);

        if (userInfoList.size() > 0) {
            if (userInfoList.get(0) != null) {
                mView.onLoginSuccess(userInfoList.get(0));
            }
        } else {
            mView.onLoginFailed("用户名或密码错误！");
        }
    }

}
